package com.cnhaimei.vod;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.List;

import android.os.Environment;
import android.util.Log;

import com.cnhaimei.vod.bean.Song;
import com.cnhaimei.vod.util.Util;


/**
 * 已选歌曲管理器 <br>
 * 
 * @author funwell <br>
 * @date 2013-7-27
 * 
 */
public class SelSongsManager {
	private final static SelSongsManager mG = new SelSongsManager();
	private List<Song> mSongList = null;

	public enum OperateResultType {
		SUCCESS, //成功
		FAIL, //失败
		EXIST_ALREADY, //已存在
	}
	
	private SelSongsManager() {
		mSongList = new ArrayList<Song>();
	}

	public static SelSongsManager G() {
		return mG;
	}
	
	public void addSong(Song song) {
		if (mSongList != null) {
			for (Song item : mSongList) {
				if (item.getName().equals(song.getName()) && item.getSingerName().equals(song.getSingerName())) {
					return ;
				}
			}
			
			mSongList.add(song);
		}
	}
	
	public void deleteSong(int index) {
		if (mSongList != null) {
			mSongList.remove(index);
		}
	}
	
	public void deleteSong(Song song) {
		if (mSongList != null) {
			for (Song item : mSongList) {
				if (item.getName().equals(song.getName()) && item.getSingerName().equals(song.getSingerName())) {
					mSongList.remove(item);
					break;
				}
			}
		}
	}
	
	public boolean isSongSelected(Song song) {
		if (mSongList != null) {
			for (Song item : mSongList) {
				if (item.getName().equals(song.getName()) && item.getSingerName().equals(song.getSingerName())) {
					return true;
				}
			}
		}
		
		return false;
	}	

}
